/**
 * Created by maxiaoqiang on 2018/7/12.
 */
import React, {Component} from "react";

import {Table, Modal} from 'antd';

import ProducePaperHeader from "component/header/ProducePaperHeader";

import ExamCountDown from "component/exam/ExamCountDown";
import ExamContent from "component/exam/ExamContent";


import moment from "moment";

import "./index.less";

const columns = [
    {
        title: '年份',
        dataIndex: 'name',
        align: "center"
    }, {
        title: '试卷名称',
        dataIndex: 'age',
        align: "center"
    }, {
        title: '难度等级',
        dataIndex: 'grade',
        align: "center"
    }, {
        title: '及格线/总分',
        dataIndex: 'pass_value',
        align: "center",
        render: (text, record) => {
            return (
                <div>
                    {record.pass_value}/100
                </div>
            )
        }
    }, {
        title: '考试时间',
        dataIndex: 'start_time',
        align: "center",
        render: (text, record) => {
            return (
                <div>
                    {moment(parseInt(record.start_time * 1000)).format("YYYY-MM-DD HH:mm:ss")}<br/>
                    {moment(parseInt(record.end_time) * 1000).format("YYYY-MM-DD HH:mm:ss")}
                </div>
            )
        }
    }, {
        title: '操作',
        dataIndex: 'operation',
        align: "center",
        render: (text, record) => {
            return (
                <div>
                    <a>开始考试</a>
                </div>
            )
        }
    }
];
class Simulate extends Component {

    constructor(props) {
        super(props);
        this.state = {
            courseId: "",
            visible: true,
            dataSource: [{
                key: '0',
                name: '2018',
                grade: "1",
                pass_value: "60",
                start_time: "1534330584",
                end_time: "1534341384",
                age: '一级建造师法规试卷',
            }, {
                key: '1',
                name: '2018',
                grade: "1",
                pass_value: "70",
                start_time: "1534330584",
                end_time: "1534341384",
                age: '一级建造师法规试卷',
            }]
        };
    }

    handleCommit = (data)=> {
        // 模拟考试试卷
        data.type = 0;
        console.log(data)
    };

    render() {
        return (
            <div>
                <Modal
                    style={{minWidth:'1000px'}}
                    centered
                    closable={false}
                    visible={this.state.visible}
                    footer={null}
                >
                    <div className="card-div">
                        <div
                            style={{width:"240px"}}
                            className="card-info"
                        >
                            <ExamCountDown/>
                        </div>
                        <div
                            style={{width:"600px"}}
                            className="card-info"
                        >
                            <ExamContent/>
                        </div>
                    </div>
                </Modal>

                <ProducePaperHeader
                    commit={this.handleCommit}
                />
                <div>
                    <Table
                        bordered
                        dataSource={this.state.dataSource}
                        columns={columns}
                    />
                </div>
            </div>
        )
    }
}

export default Simulate;